﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace WP7iPhone
{
    /// <summary>
    /// Helper class - given the current horizontal scroll position and the
    /// page number in question, returns the appropriate fill color for the
    /// navigation indicators.
    /// e.g. if HorizontalOffset = 480.0 and supplied parameter = 1, returns White
    ///      if HorizontalOffset = 480.0 and supplied parameter != 1, returns Black
    ///      
    /// </summary>
    public class NavColorValueConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (targetType != typeof(Brush)) {
                throw new NotImplementedException();
            }
            int page = (int)((double)value / 480.0);
            if (page == (int)Int32.Parse((string)parameter))
            {
                return new SolidColorBrush(Colors.White);
            }
            else
            {
                return new SolidColorBrush(Colors.Black);
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
